package com.lagou.controller;

import com.lagou.mapper.ArticleMapper;
import com.lagou.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

@Controller
public class LoginController {

    @Resource
    private ArticleMapper articleMapper;
    @RequestMapping(path={"/","/index"})
    public String toLoginPage( int pageon,Model model){
        List<Article> list = articleMapper.list(pageon*3,3);
        model.addAttribute("list", list);
        Integer count = articleMapper.count();
        HashMap<String, Integer> map = new HashMap<>();
        map.put("current",pageon);
        map.put("prePage",pageon-1<0?0:pageon-1);
        map.put("nextPage",pageon+1);
        model.addAttribute("pageination",map);
        return "/client/index";
    }



}
